<template>
  <div>
    <el-container style="height: 942px; border: 1px solid #0799f8;width: 1940px ">
      <el-aside width="300px" style="background-color: #262626; padding: 10px;">
        <el-menu v-if="is_options" :unique-opened=true>
          <el-submenu v-for="(submenu,index) in options" :key="submenu.id.toString()" :index="submenu.id.toString()"
                      @click.native="GetMainId(submenu)" :v-show="selectedSubmenuIndex === submenu.id"
                      style="background-color: #262626">
            <template slot="title">{{ submenu.main_task_name }}</template>
            <el-menu-item-group v-for="(group, groupIndex) in submenu.TestItemAlways_ALL" :key="groupIndex"
                                :title="groupIndex"
                                :index="groupIndex.toString() "
                                style="background-color: #262626;"
            >
              <el-menu-item v-for="(item, index) in group" :key="item.id" :index="item.id.toString()"
                            style="background-color: #262626;"
                            @click="TestTwo(item,groupIndex)"
              >
                <el-checkbox v-model="checkedItems[item.id]" @change="TestALL(item.id)">
                  {{ item.values }}
                </el-checkbox>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>

        <div v-else>
          数据加载中... <!-- 或者显示其他的加载状态 -->
        </div>
      </el-aside>
      <!--      <div v-if="this.tableData != ''">-->
      <el-container v-if="tableData != ''">

        <el-main style="flex: 1; display: flex; flex-direction: column;">
          <el-descriptions title="导轨位置">
            <el-descriptions-item label="导轨名称">
              <el-select v-model="tableData.GuideRailPosition.id" placeholder="请选择"
                         @change="UpdateTableDataGuideRailPosition" filterable>
                <el-option
                    v-for="(item,index) in cmslocationlist"
                    :key="item.id"
                    :label="item.cms_auto_name"
                    :value="item.id">
                  {{ item.cms_auto_name }}
                </el-option>
              </el-select>

            </el-descriptions-item>
            <el-descriptions-item label="主导轨前后">{{
                this.tableData.GuideRailPosition.cms_auto_17
              }}
            </el-descriptions-item>
            <el-descriptions-item label="屏幕升降">{{
                this.tableData.GuideRailPosition.cms_auto_4
              }}
            </el-descriptions-item>
            <el-descriptions-item label="屏幕三轴Y">{{
                this.tableData.GuideRailPosition.cms_auto_5
              }}
            </el-descriptions-item>
            <el-descriptions-item label="屏幕三轴R">{{
                this.tableData.GuideRailPosition.cms_auto_6
              }}
            </el-descriptions-item>
            <el-descriptions-item label="屏幕三轴P">{{
                this.tableData.GuideRailPosition.cms_auto_7
              }}
            </el-descriptions-item>
            <el-descriptions-item label="散射光源X">{{
                this.tableData.GuideRailPosition.cms_auto_13
              }}
            </el-descriptions-item>
            <el-descriptions-item label="散射光源Y">{{
                this.tableData.GuideRailPosition.cms_auto_14
              }}
            </el-descriptions-item>
            <el-descriptions-item label="散射光源R">{{
                this.tableData.GuideRailPosition.cms_auto_15
              }}
            </el-descriptions-item>
            <el-descriptions-item label=照度计升降>{{
                this.tableData.GuideRailPosition.cms_auto_9
              }}
            </el-descriptions-item>
            <el-descriptions-item label=照度计左右>{{
                this.tableData.GuideRailPosition.cms_auto_10
              }}
            </el-descriptions-item>
            <el-descriptions-item label=照度计前后上移动>{{ this.tableData.GuideRailPosition.cms_auto_11 }}
            </el-descriptions-item>
            <el-descriptions-item label=照度计前后下移动>{{ this.tableData.GuideRailPosition.cms_auto_12 }}
            </el-descriptions-item>
            <el-descriptions-item label=圆弧角度>{{
                this.tableData.GuideRailPosition.cms_auto_16
              }}
            </el-descriptions-item>
            <el-descriptions-item label=镜头升降>{{
                this.tableData.GuideRailPosition.cms_auto_8
              }}
            </el-descriptions-item>
            <el-descriptions-item label=镜头三轴P>{{
                this.tableData.GuideRailPosition.cms_auto_0
              }}
            </el-descriptions-item>
            <el-descriptions-item label=镜头三轴Y>{{
                this.tableData.GuideRailPosition.cms_auto_1
              }}
            </el-descriptions-item>
            <el-descriptions-item label=镜头三轴R>{{
                this.tableData.GuideRailPosition.cms_auto_2
              }}
            </el-descriptions-item>
            <el-descriptions-item label=镜头左右>{{
                this.tableData.GuideRailPosition.cms_auto_3
              }}
            </el-descriptions-item>

          </el-descriptions>
          <el-descriptions title="I29配置"
                           v-if="TestName !== '帧率' && TestName !== '闪烁' && TestName !== '系统延时' && TestName !== '成像时间'">
            <el-descriptions-item label="相机配置名称">

              <el-select v-model="tableData.I29Position.id" placeholder="请选择" @change="UpdateTableDataI29Position"
                         filterable>
                <el-option
                    v-for="(item,index) in I29"
                    :key="item.id"
                    :label="item.name_file"
                    :value="item.id">
                  {{ item.name_file }}
                </el-option>

              </el-select>
            </el-descriptions-item>
            <el-descriptions-item label="自动曝光">{{ this.tableData.I29Position.is_exposure }}</el-descriptions-item>
            <el-descriptions-item label="焦距距离">{{
                this.tableData.I29Position.focus_distance
              }}
            </el-descriptions-item>
            <el-descriptions-item label="光圈数值">{{ this.tableData.I29Position.aperture }}</el-descriptions-item>
            <el-descriptions-item label="颜色矫正">{{
                this.tableData.I29Position.color_calibration_value
              }}
            </el-descriptions-item>
            <el-descriptions-item label="色偏矫正">{{
                this.tableData.I29Position.color_shiftCorrection_value
              }}
            </el-descriptions-item>
            <el-descriptions-item label="滤光片红">{{
                this.tableData.I29Position.is_filter_state_red
              }}
            </el-descriptions-item>
            <el-descriptions-item label="曝光时间红">{{
                this.tableData.I29Position.filter_state_red
              }}
            </el-descriptions-item>
            <el-descriptions-item label="滤光片绿">{{
                this.tableData.I29Position.is_filter_state_green
              }}
            </el-descriptions-item>
            <el-descriptions-item label=曝光时间绿>{{
                this.tableData.I29Position.filter_state_green
              }}
            </el-descriptions-item>
            <el-descriptions-item label=滤光片蓝>{{
                this.tableData.I29Position.is_filter_state_blue
              }}
            </el-descriptions-item>
            <el-descriptions-item label=曝光时间蓝>{{
                this.tableData.I29Position.filter_state_blue
              }}
            </el-descriptions-item>
            <el-descriptions-item label=滤光片xb>{{ this.tableData.I29Position.is_filter_state_xb }}
            </el-descriptions-item>
            <el-descriptions-item label=曝光时间xb>{{ this.tableData.I29Position.filter_state_xb }}
            </el-descriptions-item>

          </el-descriptions>
          <el-descriptions title="灯光配置" :colon="false">
            <el-descriptions-item label="灯光名称:">

              <el-select v-model="tableData.LightPosition.id" placeholder="请选择" @change="LightPositionLightPosition"
                         filterable>
                <el-option
                    v-for="(item,index) in light_list"
                    :key="item.id"
                    :label="item.username"
                    :value="item.id">
                  {{ item.username }}
                </el-option>
              </el-select>
            </el-descriptions-item>
            <el-descriptions-item label="灯光色温:">{{ this.tableData.LightPosition.cct }}</el-descriptions-item>
            <el-descriptions-item label="灯光照度:">{{ this.tableData.LightPosition.lux }}</el-descriptions-item>
            <el-descriptions-item label="850mm:">{{ this.tableData.LightPosition.eight }}</el-descriptions-item>
            <el-descriptions-item label="940mm:">{{ this.tableData.LightPosition.nine }}</el-descriptions-item>
            <el-descriptions-item label=""></el-descriptions-item>
            <!--            <el-descriptions-item label="940mm">{{ this.tableData.LightPosition.nine }}</el-descriptions-item>-->

            <el-descriptions-item label="图卡补光光源:">
              <el-button type="success" @click="OneTwoStart" style="align-self: flex-end;">开启</el-button>
            </el-descriptions-item>
            <el-descriptions-item label="图卡补光光源:">
              <el-button type="success" @click="OneTwoStop" style="align-self: flex-end;">关闭</el-button>
            </el-descriptions-item>

          </el-descriptions>
          <el-descriptions title="帧率设置" v-if="TestName==='帧率'">

            <el-descriptions-item label="帧率">
              <el-input v-model="tableData.timer_hz" class="el-input__inne2"></el-input>
            </el-descriptions-item>
            <el-descriptions-item label="开启timer">
              <el-button type="success" @click="TimerStart" style="align-self: flex-end;">开启</el-button>
            </el-descriptions-item>
            <el-descriptions-item label="关闭timer">
              <el-button type="success" @click="TimerStop" style="align-self: flex-end;">关闭</el-button>
            </el-descriptions-item>

            <el-descriptions-item label="Timer导轨">
              手动
            </el-descriptions-item>


          </el-descriptions>

          <el-descriptions title="OF500设置"
                           v-if="TestName==='对比度复现/日落' || TestName==='弥散' || TestName==='光晕和炫光'">
            <el-descriptions-item label="OF500导轨">
              手动
            </el-descriptions-item>
            <el-descriptions-item label="开启OF500光源">
              <el-button type="success" @click="OF500Start" style="align-self: flex-end;">开启</el-button>
            </el-descriptions-item>
            <el-descriptions-item label="关闭OF500光源">
              <el-button type="success" @click="OF500Stop" style="align-self: flex-end;">关闭</el-button>
            </el-descriptions-item>
            <el-descriptions-item label="OF500光源角度" v-if="TestName==='对比度复现/日落' || TestName==='弥散'">
              <div style="color: red !important">请手动将OF500发光口旋转与水平夹角10°</div>
            </el-descriptions-item>
            <el-descriptions-item label="OF500光源角度" v-if="TestName==='光晕和炫光'">
              <div style="color: red !important">请手动将OF500发光口旋转至水平0°</div>
            </el-descriptions-item>

          </el-descriptions>
          <el-descriptions title="天空散射灯配置" v-if="TestName==='闪烁'">

            <el-descriptions-item label="灯光名称">

              <el-select v-model="tableData.KeylightPosition.id" placeholder="请选择"
                         @change="LightPositionLightPosition"
                         filterable>
                <el-option
                    v-for="(item,index) in skylight_list"
                    :key="item.id"
                    :label="item.sky_username"
                    :value="item.id">
                  {{ item.sky_username }}
                </el-option>
              </el-select>
            </el-descriptions-item>
            <el-descriptions-item label="灯光色温">{{ this.tableData.LightPosition.cct }}</el-descriptions-item>
            <el-descriptions-item label="灯光照度">{{ this.tableData.LightPosition.lux }}</el-descriptions-item>
            <el-descriptions-item label="850mm">{{ this.tableData.LightPosition.eight }}</el-descriptions-item>
            <el-descriptions-item label="940mm">{{ this.tableData.LightPosition.nine }}</el-descriptions-item>

          </el-descriptions>
          <el-descriptions title="PL1C05设置" v-if="TestName==='对比度复现/直接日光照射'">

            <el-descriptions-item label="PL1C05导轨">
              手动
            </el-descriptions-item>
            <el-descriptions-item label="开启PL1C05">
              <el-button type="success" @click="PL1C05Start" style="align-self: flex-end;">开启</el-button>
            </el-descriptions-item>
            <el-descriptions-item label="关闭PL1C05">
              <el-button type="success" @click="PL1C05Stop" style="align-self: flex-end;">关闭</el-button>
            </el-descriptions-item>


          </el-descriptions>
          <el-descriptions title="双点光源设置" v-if="TestName==='双点光源'">

            <el-descriptions-item label="双点光源导轨">
              手动
            </el-descriptions-item>
            <el-descriptions-item label="开启双点光源">
              <el-button type="success" @click="TwoPointLightStart" style="align-self: flex-end;">开启</el-button>
            </el-descriptions-item>
            <el-descriptions-item label="开启双点光源">
              <el-button type="success" @click="TwoPointLightStop" style="align-self: flex-end;">关闭</el-button>
            </el-descriptions-item>


          </el-descriptions>

          <el-descriptions title="景深卡" v-if="TestALLName==='景深|分辨率'">
            <el-descriptions-item label="景深卡导轨">
              手动
            </el-descriptions-item>
          </el-descriptions>

          <el-descriptions title="Filcker" v-if="TestName==='成像时间' || TestName==='系统延时' || TestName==='闪烁'">
            <el-descriptions-item label="通道增益">
              <el-select v-model="Filcker_GainIndex" placeholder="请选择"
                         filterable>
                <el-option
                    v-for="(item,index) in Filcker_GainIndex_list"
                    :key="item.id"
                    :label="item.value"
                    :value="item.id">
                  {{ item.value }}
                </el-option>
              </el-select>
            </el-descriptions-item>
            <el-descriptions-item label="采样频率">
              <el-select v-model="Filcker_FreIndex" placeholder="请选择"
                         filterable>
                <el-option
                    v-for="(item,index) in Filcker_FreIndex_list"
                    :key="item.id"
                    :label="item.value"
                    :value="item.id">
                  {{ item.value }}
                </el-option>
              </el-select>
            </el-descriptions-item>

            <el-descriptions-item label="采集时间">
              <el-input v-model="acquisition_time" class="el-input__inne2"></el-input>
            </el-descriptions-item>
            <el-descriptions-item label="采集数据">
              <el-button type="success" @click="StartCollection" style="align-self: flex-end;">开始采集</el-button>
            </el-descriptions-item>
          </el-descriptions>
          <el-button type="success" @click="TestUpdate" style="align-self: flex-end;">确认修改</el-button>

        </el-main>

      </el-container>
      <div v-else class="loading-container">
        LIMS ---  CMS <!-- 或者显示其他的加载状态 -->
      </div>
      <!--      </div>-->

    </el-container>
    <el-button type="success" @click="bring">开始任务</el-button>
    <!--    <Footer/>-->
  </div>


</template>

<script>
import Footer from "@/components/common/Footer";
import {todoApis} from "@/utils/apis";

export default {
  created() {
    this.ListMainTask()
  },
  data() {
    return {
      main_take_name: '',
      selectedSubmenuIndex: null,
      tableData: '',
      options: [],
      I29: '',
      light_list: '',
      skylight_list: '',
      cmslocationlist: '',
      checkedItems: [],
      selectedItems: [],
      main_id: '',
      is_options: false,
      num: 1,
      TestName: '',
      TestALLName: '',
      Filcker_GainIndex: 0,
      Filcker_FreIndex: 0,
      Filcker_GainIndex_list: [
        {'id': 0, 'value': "*1K"},
        {'id': 1, 'value': "*100K"},
        {'id': 2, 'value': "*10M"},
        {'id': 3, 'value': "*1G"},
      ],
      Filcker_FreIndex_list: [
        {'id': 0, 'value': "2.5M BPS"},
        {'id': 1, 'value': "2M BPS"},
        {'id': 2, 'value': "1M BPS"},
        {'id': 3, 'value': "500K BPS"},
        {'id': 4, 'value': "400K BPS"},
        {'id': 5, 'value': "200K BPS"},
        {'id': 6, 'value': "100K BPS"},
      ],
      acquisition_time: 0,
    };
  },
  components: {
    Footer,
  },
  methods: {
    // 开始采集
    StartCollection() {
      this.$axios.get(this.$settings.BASE_URL + `filcker/datacollection/?gainIndex=${this.Filcker_GainIndex}&Frequency=${this.Filcker_FreIndex}&acquisition_time=${this.acquisition_time}`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 开启PL1C05
    PL1C05Start() {
      this.$axios.get(this.$settings.BASE_URL + `pl1c05/setpl1C05lighttrue/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 开启PL1C05
    PL1C05Stop() {
      this.$axios.get(this.$settings.BASE_URL + `pl1c05/setpl1C05lightfalse/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 开启双点光源
    TwoPointLightStart() {
      this.$axios.get(this.$settings.BASE_URL + `twopoint/twopointstart/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    //关闭双点光源
    TwoPointLightStop() {
      this.$axios.get(this.$settings.BASE_URL + `twopoint/twopointstop/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 开启OF500
    OF500Start() {
      this.$axios.get(this.$settings.BASE_URL + `of500/setlighttrue/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 关闭OF500
    OF500Stop() {
      this.$axios.get(this.$settings.BASE_URL + `of500/setlightfalse/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 开启图卡补光光源
    OneTwoStart() {
      this.$axios.get(this.$settings.BASE_URL + `lightauto/onetwostart/?lux=${this.tableData.LightPosition.lux}&cct=${this.tableData.LightPosition.cct}&eight=${this.tableData.LightPosition.eight}&nine=${this.tableData.LightPosition.nine}`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 关闭图卡补光光源
    OneTwoStop() {
      this.$axios.get(this.$settings.BASE_URL + `lightauto/onetwostop/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 获取天空散射光列表
    SkyLightList() {
      this.$axios.get(this.$settings.BASE_URL + `lightauto/skylights/`).then((res) => {
        if (res.data.code == 100) {
          this.skylight_list = res.data.data
        }
      })
    },
    // 开启timer
    TimerStart() {
      this.$axios.get(this.$settings.BASE_URL + `timer/timerparameter/?hz=${this.tableData.timer_hz}`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        }
      })
    },
    // 关闭Timer
    TimerStop() {
      this.$axios.get(this.$settings.BASE_URL + `timer/timerstop/`).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    // 修改任务
    TestUpdate() {
      let data_Position = {
        'I29': this.tableData.I29Position.id,
        'is_picture': this.tableData.is_picture,
        'picture': this.tableData.picture_one.id,
        'light': this.tableData.LightPosition.id,
        'cms_location': this.tableData.GuideRailPosition.id,
        'timer_hz': this.tableData.timer_hz,
      };

      // 如果tableData的KeylightPosition属性不为null
      if (this.tableData.KeylightPosition !== null) {
        // 将skylight属性添加到data_Position对象中
        data_Position['skylight'] = this.tableData.KeylightPosition.id;
      }
      this.$axios.put(this.$settings.BASE_URL + `picture/tests/${this.tableData.id}/`, data_Position).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
        }
      })
    },
    startPolling() {
      console.log(this.options.length, '测试')

      if (this.options.length > 0) {
        // 如果已经有选项了，停止查询
        this.is_options = true
        this.$set(this, 'is_options', true);
        this.num = 5
        console.log(this.is_options)
        console.log('停止查询')
        this.$forceUpdate()

        return;
      }

      setTimeout(() => {
        // 进行查询操作
        console.log('我执行了', this.options)
        this.startPolling(); // 递归调用
      }, 5000);

    },
    // 获取主任务ID
    GetMainId(submenu) {
      this.main_id = submenu.id
    },
    TestALL(id) {
      // 根据id判断是勾选还是取消勾选
      if (this.selectedItems.includes(id)) {
        // 如果已经在selectedItems中，说明是取消勾选，需要从列表中移除
        const index = this.selectedItems.indexOf(id);
        this.selectedItems.splice(index, 1);
      } else {
        // 如果不在selectedItems中，说明是勾选，需要添加到列表中
        this.selectedItems.push(id);
      }
    },
    // 查找当前导轨的配置值
    UpdateTableDataGuideRailPosition() {
      this.$axios.get(this.$settings.BASE_URL + 'cmsauto/cmsautolist/' + `${this.tableData.GuideRailPosition.id}` + '/').then((res) => {
        if (res.data.code == 100) {
          this.tableData.GuideRailPosition = res.data.data
        }
      })
    },
    // 查找当前I29配置
    UpdateTableDataI29Position() {
      this.$axios.get(this.$settings.BASE_URL + `brightness_auto/i29list/${this.tableData.I29Position.id}/`).then((res) => {
        if (res.data.code == 100) {
          this.tableData.I29Position = res.data.data
        }
      })
    },
    LightPositionLightPosition() {
      this.$axios.get(this.$settings.BASE_URL + `lightauto/lightnopage/${this.tableData.LightPosition.id}/`).then((res) => {
        if (res.data.code == 100) {
          this.tableData.LightPosition = res.data.data
        }
      })
    },
    // 获取测试项下的配置
    TestOne(item, submenu) {
      this.$axios.get(this.$settings.BASE_URL + 'picture/tests/' + `?TestItem=${item.id}`).then((res) => {
        if (res.data.code == 100) {
          this.TestALLName = submenu
          this.TestName = item.values
          this.tableData = ''
        }
      })
    },
    TestTwo(item, submenu) {
      this.$axios.get(this.$settings.BASE_URL + 'picture/tests/' + `?TestItem=${item.id}`).then((res) => {
        if (res.data.code == 100) {
          this.TestALLName = submenu
          this.TestName = item.values
          this.tableData = res.data.data
        }
      })
    },
    // 开始任务
    //   TaskCopy(){
    //   this.$axios.get(this.$settings.BASE_URL+`task/maintaskcopy/?main_task_name=${}`).then((res)=>{
    //
    //   })
    //   },
    bring() {
      this.$axios.get(this.$settings.BASE_URL + 'task/bring/' + `?main=${this.main_id}&tasks_id=${this.selectedItems}`).then((res) => {
        if (res.data.code == 100) {

        }
      })
    },
    // 获取导轨位置
    GetCmsLocationList() {
      this.$axios.get(this.$settings.BASE_URL + 'cmsauto/cmsautolist/').then((res) => {
        if (res.data.code == 100) {
          this.cmslocationlist = res.data.data
        }

      })
    },
    // 更新图卡列表
    updateGraphicCard(item) {
      // 根据选择更新图卡列表
      this.card_list = this.TestList[item - 1]['picture_relevance_in_one']
    },
    // 跟新测试项列表
    updateTestItems(item) {
      // 根据选择更新测试项列表
      this.$axios.get(this.$settings.BASE_URL + 'picture/testones/' + `?id=${item}`).then((res) => {
        if (res.data.code == 100) {
          this.TestList = res.data.data
        }
      })
    },
    // 获取图卡配置
    CardList() {
      this.$axios.get(this.$settings.BASE_URL + 'picture/cards/').then((res) => {
        if (res.data.code == 100) {
          this.card_list = res.data.data
        }
      })
    },
    // 获取灯光配置
    LightList() {
      this.$axios.get(this.$settings.BASE_URL + 'lightauto/lightnopage/').then((res) => {
        if (res.data.code == 100) {
          this.light_list = res.data.data
        }
      })
    },
    // 获取I29配置
    I29List() {

      this.$axios.get(this.$settings.BASE_URL + 'brightness_auto/i29list/').then((res) => {
        if (res.data.code == 100) {
          this.I29 = res.data.data
        }
      })
    },

    // 查询测试项
    GetTestList() {
      this.$axios.get(this.$settings.BASE_URL + 'picture/tests/').then((res) => {
        if (res.data.code == 100) {
          this.TestList = res.data.data
        }
      })
    },
    handleClose_is_createtask(done) {
      this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {
          });
    },
    createtask_dlg() {
      this.I29List()
      this.LightList()
      this.GetCmsLocationList()
    },
    createtask() {
      this.$axios.post(this.$settings.BASE_URL + 'task/taskcreate/', {
        task_name: this.subtask,
        main: this.main_id,
        I29: this.I29_name,
        picture: this.picture_name,
        light: this.light_name,
        test_item: this.test_item_name,
        cms_location: this.cmslocation

      }).then((res) => {
        if (res.data.code == 100) {
          this.$message({
            message: res.data.msg,
            type: 'success'
          });
          this.tableData = res.data.data
          this.is_createtask = false
        }
      }).catch(error => {
            this.$message.error(error);
          }
      );
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    // 获取当前主任务下的子任务

    // 获取所有主任务
    // async ListMainTask() {
    //   try {
    //     const res = await this.$axios.get(this.$settings.BASE_URL + 'task/maintask/');
    //     if (res.data.code === 100) {
    //       // this.$set(this.options,res.data.data)
    //       this.options = res.data.data;
    //       this.tableData = res.data.data[0]['task_list'];
    //       this.main_id = res.data.data[0]['id'];
    //       console.log(this.options, 'options');
    //     } else {
    //       this.options = ['任务获取失败'];
    //     }
    //   } catch (error) {
    //     console.error(error);
    //     this.options = ['发生了错误'];
    //   }
    // },
    ListMainTask() {
      try {
        this.$axios.get(this.$settings.BASE_URL + 'task/maintask/').then((res) => {
          if (res.data.code === 100) {
            this.options = res.data.data;
            this.tableData = res.data.data[0]['task_list'];
            this.main_id = res.data.data[0]['id'];
            console.log(this.options, 'options');
            console.log('先走的ListMainTask')
            this.createtask_dlg()
            this.TestOne({'id': 1}, '帧率')
            this.SkyLightList()
            this.startPolling()
          } else {
            this.options = ['任务获取失败'];
          }
        });

      } catch (error) {
        console.error(error);
        this.options = ['发生了错误'];
      }
    },
  }
// 获取主任务下的测试项下的子测试项
}
;
</script>

<style lang="less">


.el-checkbox {
  color: #ccc;
}

//.el-menu-item:hover {
//color: #262626;
//background-color: #262626 !important;
//}

.el-menu-item-group__title {
  font-size: 17px;
  background-color: #262626;
}

.el-menu .el-select-dropdown {
  background-color: black !important;
  color: white !important;
}

.el-header {
  background-color: #B3C0D1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}

.active {
  color: blue; /* 设置蓝色文字 */
}

.page-todo {
  .myDiv {
    height: 200px
  }

  // 检测屏幕宽度 自适应
  @media screen and (min-width: 1024px) and (max-width: 1500px) {
    .el-button {
      height: @h*3.7037037vh;
      line-height: 1;
      padding: 5px 8px;
      font-size: 1rem;
    }
  }

  .todo-box {
    // margin: @h*14vh @w*28vw 0 @w*32vw;
    display: flex;
    background: #2e2e2e;
    height: @h*1000vh;

    .left {
      margin-top: @h*20vh;
      width: @w*550vw;
      margin-left: @w*18vw;
      border: 1px solid #666;
      margin-bottom: @h*33vh;

      .el-menu-vertical-demo:not(.el-menu--collapse) {
        width: 200px;
        min-height: 400px;
      }

      .btn-box {
        height: @h*60vh;
        border-bottom: 1px solid #666;
        text-align: center;

        .maintask {
          height: @h*60vh;
          line-height: @h*60vh;
          width: @w*100vw;
          float: left;
        }

        .el-button {
          margin: @h*4vw @w*5vw;
          padding: @h*5vw @w*5vw;
          height: @h*20vw;
        }

        .el-dialog {
          width: @w*530vw;

          // height:@h*490vh;
          .el-dialog__header {
            height: @h*66vh;
            line-height: @h*66vh;
            border-bottom: 1px solid #ccc;
            padding: 0;
            padding-left: @w*40vw;
            text-align: left;
          }

          .el-dialog__body {
            padding: @h*40vh @w*50vw;

            .el-form-item {
              // margin-bottom: @h*40vh;
              display: flex;
            }

            .el-form-item__label {
              width: @w*130vw;
            }
          }

          .el-dialog__footer {
            text-align: center;
            // padding: 0;
          }
        }
      }

      .todo-list {
        display: flex;
        flex-direction: column;

        .active {
          background: rgba(22, 143, 255, 0.3);
          border-right: 2px solid rgba(22, 143, 255);
        }

        .todo-list-item {
          height: @h*60vh;
          line-height: @h*60vh;
          padding-left: @w*12vw;
          cursor: pointer;

          .spans {
            width: @w*200vw;
          }

          .num {
            margin-left: @w*8vw;
          }

          .el-checkbox__label {
            font-size: 1rem;
            font-family: Source Han Sans CN;
            font-weight: 400;
            color: #ffffff;
            width: 100%;
          }
        }
      }

      // 提示框样式
      .el-dialog {
      }
    }

    .right {
      margin: @h*20vh @w*22vw @h*33vh @w*20vw;
      width: 89.666667vw;
      border: 1px solid #666;

      // height: 866px;
      .sub-todo-info {
        .sub-top {
          height: @h*60vh;
          line-height: 5.407407vh;
          border-bottom: 1px solid #666;

          .top-title {
            float: left;
            padding-left: 3%;
            font-size: 1.125rem;
            font-family: Source Han Sans CN;
            font-weight: 400;
            color: #ffffff;
          }

          .top-add {
            float: right;
            padding-right: 3%;

            .el-dialog {
              width: @w*880vw;

              // height:@h*490vh;
              .el-dialog__header {
                height: @h*66vh;
                line-height: @h*66vh;
                border-bottom: 1px solid #ccc;
                padding: 0;
                padding-left: @w*40vw;
              }

              .el-dialog__body {
                padding: @h*40vh @w*50vw;

                .el-form {
                  overflow: hidden;
                }

                .el-form-item {
                  margin-bottom: @h*40vh;
                  display: flex;
                  float: left;
                }

                .el-form-item__label {
                  width: @w*130vw;
                }
              }

              .el-dialog__footer {
                text-align: center;
              }
            }

            .el-button {
              width: @w*130vw;
              height: @h*40vh;
              text-align: center;
              border: none;
              // line-height: @h*40vh ;
            }
          }
        }

        .table {
          background: #2e2e2e;

          .el-dialog {
            width: @w*880vw;

            // height:@h*490vh;
            .el-dialog__header {
              height: @h*66vh;
              line-height: @h*66vh;
              border-bottom: 1px solid #ccc;
              padding: 0;
              padding-left: @w*40vw;
            }

            .el-dialog__body {
              padding: @h*40vh @w*50vw;

              .el-form {
                overflow: hidden;
              }

              .el-form-item {
                margin-bottom: @h*40vh;
                display: flex;
                float: left;
              }

              .el-form-item__label {
                width: @w*130vw;
              }
            }

            .el-dialog__footer {
              text-align: center;
            }
          }

          .el-table__body-wrapper {
            background: #2e2e2e;
          }

          .el-table th {
            background: #383838;
            color: #fff;
            border-bottom: 1px solid #666;
            border-right: 1px solid #666;
            // height: 60px;
            // padding: 0;
          }

          .el-table tr {
            background: #2e2e2e;
            color: #fff;
            // height: 60px;
          }

          .el-table td {
            border-bottom: 1px solid #666;
            border-right: 1px solid #666;
            // padding: 0;
          }

          /* .el-table th.is-leaf {
            border-bottom: 1px solid #666;
            border-right: 1px solid #666;
          } */

          .el-table::before {
            background-color: #666;
          }

          .el-table--enable-row-hover .el-table__body tr:hover > td {
            background-color: #2e2e2e;
          }
        }
      }
    }
  }
}

.el-aside {
  background-color: #f0f4f9; /* 柔和的蓝灰色 */
  color: #333333; /* 深灰色 */
}

/* 菜单项背景颜色、文字颜色 */
.el-menu-item, .el-submenu {
  background-color: #262626; /* 白色背景 */
  color: #333333; /* 深灰色 */
}

.el-descriptions__body .el-descriptions__table .el-descriptions-item__cell {
  line-height: 2.2;
  background-color: #262626
}

/* 菜单项激活状态样式 */
.el-menu-item.is-active, .el-submenu.is-active {
  background-color: #f0f9ff; /* 淡蓝色 */
}

.el-input__inner {
  background-color: #262626;
  border-radius: 31px;
  height: 34px
}

.el-input__inne2 {
  background-color: #262626;
  border-radius: 31px;
  height: 34px;
  width: 30%
}

.el-input__icon {
  line-height: 33px
}

/* 按钮样式 */
.el-button {
  background-color: #409eff; /* 鲜艳的蓝色 */
  color: #ffffff; /* 白色 */
  border-radius: 0px;
}

.el-button:hover {
  background-color: #66b1ff; /* 淡蓝色 */
}

/* 描述列表样式 */
.el-descriptions {
  background-color: #262626; /* 白色背景 */
  border: 1px solid #ebeef5; /* 淡蓝色边框 */
}

.el-descriptions-item {
  color: #ccc; /* 深灰色 */
}

.el-descriptions {
  color: #ccc; /* 深灰色 */
}

.el-submenu__title {
  color: #ccc; /* 深灰色 */
}

/* 表单元素样式 */
.el-form-item__label {
  color: #333333; /* 深灰色 */
}

.el-input {
  border-color: #dcdfe6; /* 浅灰色边框 */
}

.el-select {
  //border-color: #dcdfe6; /* 浅灰色边框 */
  //background-color: black; /* 设置背景颜色为黑色 */
  //color: white; /* 设置文字颜色为白色 */
}

.el-select-dropdown .el-select-dropdown__item {
  background-color: #262626; /* 设置背景颜色为白色 */
}

.el-select-dropdown__list {
  background-color: #262626
}

.el-descriptions-item__label {
  color: #ccc; /* 深灰色 */
}

/* 下拉选择框样式 */
//.el-select {
//  width: 10%; /* 设置宽度为100% */
//}

.el-select__input {
  height: 20px; /* 设置输入框高度 */
  border-color: #dcdfe6; /* 浅灰色边框 */
}

.el-select__caret {
  color: #909399; /* 灰色下拉箭头 */
}

.el-option {
  color: #333333; /* 深灰色 */
}

.el-option:hover {
  background-color: #f0f9ff; /* 鼠标悬停时的背景颜色 */
}

.el-option.is-selected {
  background-color: #409eff; /* 已选项的背景颜色 */
  color: #ffffff; /* 白色文本 */
}

.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 89vh; /* 设置高度为视窗的100% */
  transform: scale(1.5); /* 放大1.5倍，可以根据需要调整 */
  margin: 0 auto; /* 将元素水平居中 */

  opacity: 1; /* 设置透明度为50%，使其镂空 */
  color: white; /* 设置文字颜色为白色 */
  padding: 0px; /* 可选：增加内边距，使文字与边界有间距 */
  border-radius: 10px; /* 可选：添加圆角边框 */
  font-size: 100px; /* 设置文字大小为 20 像素，可以根据需要调整 */
  color: transparent; /* 将文字颜色设为透明 */
  -webkit-text-stroke: 2px #00A8FC; /* 设置文字镂空效果，1px是描边的宽度，black是描边的颜色 */
  text-fill-color: transparent; /* 兼容性设置，使得在某些浏览器中也可以显示镂空效果 */
}

/* 如果需要更多样式调整，请随时告诉我！ */
</style>
